package com.dxp.operation.vo.respose.base;

import com.dxp.operation.exception.ErrEnum;
import lombok.Data;

import java.io.Serializable;

/**
 * @author carzy
 */
@Data
public class Result<T> implements Serializable {

    private int error;

    private String msg;

    private T data;

    public static <T> Result<T> suc(T data) {
        Result<T> result = new Result<>();
        result.setData(data);
        result.setError(0);
        result.setMsg("");
        return result;
    }

    public static <T> Result<T> err(T data, ErrEnum errEnum) {
        Result<T> result = new Result<>();
        result.setData(data);
        result.setError(errEnum.code());
        result.setMsg(errEnum.msg());
        return result;
    }
}
